/**
 * 每个月都是30天，每周都是5天。
 * 给定一个日期与星期，再给另一个日期，问是星期几
 * 其实跟年月没有太大关系，只是用来判前后的
 * 就用日期相减，然后对5取即可
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;

using llt = int;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

const array<string, 5> Week {
    "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"
};

int Y1, M1, D1;
int Y2, M2, D2;
string W1;

int get(const string & s){
    for(int i=0;i<5;++i)if(Week[i] == s)return i;
    assert(0);
    return -1;
}

int proc(){
    int d = D2 - D1;
    if(Y2 < Y1 or (Y2 == Y1 and M2 < M1) or (Y2 == Y1 and M2 == M1 and D2 < D1)) d = d - 30;

    d %= 5;
    d = (d + get(W1)) % 5;
    if(d < 0) d += 5;
    return d;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0);
    int nofkase = 1;
    cin >> nofkase;
    while(nofkase--){
        cin >> Y1 >> M1 >> D1 >> W1 >> Y2 >> M2 >> D2;
        cout << Week[proc()] << endl;   
    }
    return 0;
}